package com.hdu.delayTask;


import com.hdu.annotation.DelayTask;
import com.hdu.result.R;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class SendMessageDelayTask {


    public static final String TASK_NAME = "sendMessage";

    @DelayTask(taskName =TASK_NAME)
    public R sendMessage(Message message) {
        log.info("开始执行任务.. message : {}", message);
        return R.success();
    }

    public static Message createMessage(String from, String to, String content) {
        return new Message(from, to, content);
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    static class Message {
        private String from;
        private String to;
        private String content;
    }
}
